The Color Dialog


The Color Dialog

The color dialog establishes a conversation with the user to request a color. When the user selects a color, the dialog ends and returns a color (a variable of the type COLORREF) to the main program.
El diálogo de color establece una conversación con el usuario para solicitar un color. Cuando el usuario selecciona un color, el diálogo termina y regresa un color (una variable del tipo COLORREF) al programa principal.

Problem 1
Create a program called Fondo as shown below. When the user presses the Color button, the dialog requests a color from the user. The selected color is, then, used to set the back color of the X-Y graph.
Cree un programa llamado Fondo como se muestra debajo. Cuando el usuario presiona el botón de Color, el diálogo solicita un color al usuario. El color seleccionado es, entonces, usado para fijar el color de fondo de la gráfica X-Y.

FondoGui

Fondo.cpp
void Fondo::Window_Open(Win::Event& e)
{
     //________________________________________________________ xy1
     xy1.CaptionX = L"Axis X";
     xy1.CaptionY = L"Axis Y";
     xy1.MinX= 0.0;
     xy1.MaxX= 6.28;
     xy1.MinY= -1.0;
     xy1.MaxY= 1.0;
     xy1.Graphs.Add(100);
     for(int i=0; i<100; i++)
     {
          xy1.Graphs[0][i].x = i*6.28/100;
          xy1.Graphs[0][i].y = sin(i*6.28/100);
     }
     xy1.RefreshAll();
}

void Fondo::btColor_Click(Win::Event& e)
{
     Win::ColorDlg dlg;
     dlg.SelectedColor = xy1.BackColor; // Set the initial color in the dialog
     if (dlg.BeginDialog(hWnd) == true)
     {
          xy1.BackColor = dlg.SelectedColor; // Change the graph color
     }
}

Fondo

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home